var showLineInfo;
require(['file1'], function () {
	var $formData = $('#formData'),$upStnLine=$("#upStnLine"),$downStnLine=$("#downStnLine");
	$('#upStnLine,#downStnLine').stationChart();
	function lineChange(event, treeId, treeNode) {
		if (treeNode.type === 'LINE') {
			searchLineInfo(treeNode.id);
		} else {
			$.messager.alert("提示", "请选择线路进行查看。");
		}
	}

	//左侧树
	commonFun.leftTreeNodeClickObj['lineAnaLineInfo'] = lineChange;

	function searchLineInfo(lineId){
		$.ajaxExt({
			url :"/lineAna/getLineInfoByLineId.htm",
			data : {'lineId' : lineId}
		}).done(function(data){
			$formData.setViewData(data);
			if(data.lineTypeId=="LIC00001"){
				$("#lineType").html("上下行");
			}else if(data.lineTypeId=="LIC00002"){
				$("#lineType").html("环行");
			}else{
				$("#lineType").html("");
			}
			if(data.throoutPrice=="" ||data.throoutPrice =="0" ||data.throoutPrice ==undefined){
				$("[name='throoutPrice']").html("-");
			}else{
				$("[name='throoutPrice']").html("最高票价："+ data.throoutPrice +"元");
			}
			
		});
		//上行
		$upStnLine.stationChart('load',"/stnLineRel/getUpStnLineRelByLineId.htm",
				{"lineId":lineId,"strtusDate":$("#initStrtusDate").val()},function(data){
					var beginStatinLine="",endStatinLine="",upStnWidth;
					$(data).each(function(i,item) {
						upStnWidth=i;
						if(i==0){
							beginStatinLine=item.stnName;
						}
							endStatinLine=item.stnName;
					});
					upStnWidth=(upStnWidth+1)*27+15;
					$(".bus-stop-list").eq(0).css("width",upStnWidth+"px");
					$("#beginStatinLine").html(beginStatinLine.replace(/(︹)(\S+)(︺)/,'($2)'));
					$("#endStatinLine").html(endStatinLine.replace(/(︹)(\S+)(︺)/,'($2)'));
				});
		//下行
	$downStnLine.stationChart('load',"/stnLineRel/getDownStnLineRelByLineId.htm",
		{"lineId":lineId,"strtusDate":$("#initStrtusDate").val()},function(data){
			var beginStatinLineDown="",endStatinLineDown="",downStnWidth;
			$(data).each(function(i,item) {
				downStnWidth=i;
				if(i==0){
					beginStatinLineDown=item.stnName;
				}
				endStatinLineDown=item.stnName;
			});
			downStnWidth=(downStnWidth+1)*27+15;
			$(".bus-stop-list").eq(1).css("width",downStnWidth+"px");
			$("#beginStatinLineDown").html(beginStatinLineDown.replace(/(︹)(\S+)(︺)/,'($2)'));
			$("#endStatinLineDown").html(endStatinLineDown.replace(/(︹)(\S+)(︺)/,'($2)'));
		});
	}
	showLineInfo = function(data){
		searchLineInfo(data.lineId);
	}
	
	//如果左侧树有选择线路则直接查询该线路数据
	business.execFnByLeftTreeSelectNode('LINE', lineChange);
});